#ifndef STATE_MOVIE_H
#define STATE_MOVIE_H

#pragma once;

#include "State.h"
#include "TwoPlayer.h"
#include "ThreePlayer.h"
#include "FourPlayer.h"
#include "enums.h"
#include <Dshow.h>
#include <stdio.h>
#include <windows.h>

#include "resource.h"

#define WM_GRAPHEVENT	WM_USER		// define a custom window message for graph events

// convenient macro for releasing interfaces
#define HELPER_RELEASE(x)   if (x != NULL) \
                            { \
                                x->Release(); \
                                x = NULL; \
                            }


class BallSmackers;

class State_Movie:public State
{
private:
	char choice;
	static State_Movie* init;

// DirectShow interfaces
IGraphBuilder*	g_pGraphBuilder;// = NULL;
IMediaControl*	g_pMediaControl;// = NULL;
IMediaEventEx*	g_pMediaEvent;// = NULL;
IMediaPosition*	g_pMediaPosition;// = NULL;

//OPENFILENAME    ofn;    // use common 'Open' control
//char            file[MAX_PATH];     // filename with path
//char            filetitle[MAX_PATH];    // thrown in to show file in title bar


int	    length;		// length of filename
WCHAR*	wfilename;	// where we store WCHAR version of filename
HRESULT hr;
HANDLE  logfile;                  // log file for graphbuilder
//DWORD_PTR	logfile;
char    logfilename[MAX_PATH];    // full path and name of log file



HINSTANCE   g_AppInstance;
HWND        g_AppWindow;


BOOL        g_Looping;// = FALSE;          // should we loop the media

char        g_ExecuteDir[MAX_PATH];     // directory of execution
//char        g_WindowTitle[] = "DShowTut2";              // text for title bar
	IDirect3DTexture9* mBkgdTex;
	D3DXVECTOR3 mBkgdCenter;


public:
	State_Movie();
	void Enter();
	void Execute(D3DApp* g);
	void Exit();
	void Draw();
	static State_Movie* Instance();
	char getChoice()const { return choice;}
	void InitDirectShow();
	void CreateGraph(char* filename);
	void CleanUpDirectShow();
	void OnGraphEvent();
	//char *file = "E:\Anime\[ainex]_Shigofumi_Trailer_[XVID][F37D7E98].avi";
};

#endif
